#pragma once
template<typename F>
struct Final_action {
	Final_action(F f) :clean{ f } {}
	~Final_action() { clean(); }
	F clean;
	Final_action(const Final_action&) = delete; //forbidden copy
	Final_action& operator=(const Final_action&) = delete;
	Final_action(Final_action&&) = default; //allowed move
	Final_action() = default;
	Final_action& operator=(Final_action&&) = default;
};
template<typename F>
Final_action<F> finally(F f) {
	return Final_action<F>(f);
}